<?php

namespace app\model;

use think\Model;
use think\model\concern\SoftDelete;

class ScenicSpots extends Model
{
    use SoftDelete;
    // Define the table name
    protected $name = 'scenic_spots';
    public $timestamps = false;
    protected $deleteTime = 'deleted_at';

    public function tickets()
    {
        return $this->hasMany(Tickets::class,  'scenic_id','id');
    }


    public function batchScenicSpotInfo($scenicIds)
    {
        $scenicSpotInfo = $this->where('id', 'in', $scenicIds)->select()->toArray();
        return $scenicSpotInfo;
    }


    public function getCoverImageAttr($value)
    {
        return env('IMAGE_URL').$value;
    }

    public function getImagesAttr($value)
    {
        $value = $value ? explode(',',$value) : [];
        return $value ? array_map(function($item){
            return env('IMAGE_URL').$item;
        },$value) : [];
    }
}
